#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2021, Intel Corporation
#
#
# pmempool_check/TEST5 -- test for checking pools
#

. ../unittest/unittest.sh

require_test_type medium
require_fs_type pmem non-pmem
require_unlimited_vm

# Valgrind cannot trace more than 32G which is required for this test
configure_valgrind force-disable

setup

POOL=$DIR/file.pool
LOG=out${UNITTEST_NUM}.log
rm -f $LOG && touch $LOG

truncate -s2T $POOL
expect_normal_exit $PMEMPOOL$EXESUFFIX create -v -w blk 512M $POOL > /dev/null
check_file $POOL
expect_normal_exit $PMEMPOOL$EXESUFFIX info $POOL > /dev/null
$PMEMSPOIL $POOL pool_hdr.checksum=0x0\
	"pmemblk.arena(1).btt_info.sig=ERROR"\
	"pmemblk.arena(1).btt_info_backup.sig=ERROR"

expect_abnormal_exit $PMEMPOOL$EXESUFFIX check -vry $POOL >> $LOG
expect_normal_exit $PMEMPOOL$EXESUFFIX check -avry $POOL >> $LOG
expect_normal_exit $PMEMPOOL$EXESUFFIX check $POOL >> $LOG
expect_normal_exit $PMEMPOOL$EXESUFFIX info $POOL > /dev/null

check

pass
